summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/time/system_clock_context_update_callback.h
blob: bf657acd9e0f273f60cb9ce297960f1337621006 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <memory>
#include <vector>

#include "core/hle/service/time/clock_types.h"

namespace Kernel {
class KEvent;
}

namespace Service::Time::Clock {

// Parts of this implementation were based on Ryujinx (https://github.com/Ryujinx/Ryujinx/pull/783).
// This code was released under public domain.

class SystemClockContextUpdateCallback {
public:
    SystemClockContextUpdateCallback();
    virtual ~SystemClockContextUpdateCallback();

    bool NeedUpdate(const SystemClockContext& value) const;

    void RegisterOperationEvent(std::shared_ptr<Kernel::KEvent>&& event);

    void BroadcastOperationEvent();

    Result Update(const SystemClockContext& value);

protected:
    virtual Result Update();

    SystemClockContext context{};

private:
    bool has_context{};
    std::vector<std::shared_ptr<Kernel::KEvent>> operation_event_list;
};

} // namespace Service::Time::Clock